import SysUtil from './utils/SysUtil'
import { ipcRenderer } from 'electron'
import { defaultHt } from './common'

const hourMinutes = 60

/**
 * 电池信息
 */
// const batteryInfo = (setBatteryInf) => {
//   SysUtil.batteryInfo().then((data) => {
//     // data.timeRemaining = Number((data.timeRemaining / hourMinutes).toFixed(2))
//     setBatteryInf({ ...data })
//     // console.log(data)
//     window.topInfo[3] = data.percent
//   })
// }

const batteryInfo = async () => {
  const data = await SysUtil.batteryInfo()
  window.topInfo[3] = data.percent
  return new Promise((resolve) => {
    resolve(data)
  })
}

const hasBattery = async () => {
  const data = await SysUtil.batteryInfo()
  return new Promise((resolve) => {
    resolve(data.hasBattery)
  })
}

/**
 * 设置窗口高度
 */
const setBatteryHt = () => {
  ipcRenderer.send('winHtChange', 274 + defaultHt)
}

export { batteryInfo, setBatteryHt, hasBattery }
